home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / lists / mint / l_1199 / 1687 < prev    next >
Encoding:
Internet Message Format  |  1994-08-27  |  11.5 KB

  1. Subject: Re: some more 110h4 clues...
  2. Date: Fri, 8 Jul 94 22:23:10 CDT
  3. From: Juergen Lock <nox@jelal.north.de>
  4. In-Reply-To: <9407051959.AA09735@pirol.techfak.uni-bielefeld.de>; from "itschere@TechFak.Uni-Bielefeld.DE" at Jul 5, 94 9:59 pm
  5. Message-Id: <9407082023.AA00649@jelal.north.de>
  6.  
  7. itschere@TechFak.Uni-Bielefeld.DE writes:
  8.  
  9. > > If my memory serves me right, this is the upwards pointer to the
  10. > > parent process' basepage.
  11. >  It *is*.
  12.  
  13.  here's the fix :)  and something else for you all to test...
  14.  
  15. 1. exec and base->p_parent...
  16.  
  17. Index: mem.c
  18. @@ -1137,8 +1137,8 @@
  19.      long len = 0, minalt = 0, coresize, altsize;
  20.      MMAP map;
  21.      MEMREGION *m, *savemem = 0;
  22. -    BASEPAGE *b;
  23. -    PROC *parent = 0;    /* keep compiler happy... */
  24. +    BASEPAGE *b, *bparent = 0;
  25. +    PROC *parent = 0;
  26.      short protmode;
  27.      int i;
  28.  
  29. @@ -1252,8 +1252,15 @@
  30.          execproc->ctxt[SYSCALL].sr |= 0x2000;
  31.          execproc->ctxt[SYSCALL].ssp = (long)(execproc->stack + ISTKSIZE);
  32.  
  33. -        if (savemem)
  34. -            fork_restore(parent, savemem);
  35. +/* save basepage p_parent */
  36. +        bparent = execproc->base->p_parent;
  37. +        if (parent) {
  38. +            if (savemem)
  39. +                fork_restore(parent, savemem);
  40. +/* blocking forks keep the same basepage for parent and child,
  41. +   so this p_parent actually was our grandparents...  */
  42. +            bparent = parent->base;
  43. +        }
  44.          for (i = 0; i < execproc->num_reg; i++) {
  45.              m = execproc->mem[i];
  46.              if (m && m->links == 0xfffe) {
  47. @@ -1323,6 +1330,11 @@
  48.      b->p_env = (char *)env->loc;
  49.      b->p_flags = flags;
  50.  
  51. +    if (execproc) {
  52. +        execproc->base = b;
  53. +        b->p_parent = bparent;
  54. +    }
  55. +
  56.      if (cmd)
  57.          strncpy(b->p_cmdlin, cmd, 126);
  58.      return m;
  59.  
  60. 2. serial lines...  use the xcon* pointers etc. available thru
  61. Bconmap(-2), set DTR on SCC ports and hack around a bunch of BIOS bugs
  62. while we're at it, including TIOCSBRK for SCC ports.  you still need to
  63. load debugged drivers (before MiNT!) to get reliable flow control and
  64. stop losing chars on all TOS versions _i_ know, your mileage may vary...
  65. at least the remaining bugs should not affect the rest of the system
  66. anymore. (except for the mega STe SCC/DMA hardware bug of course...)
  67.  
  68. please test this, hard. :)  the MAPTAB stuff is official (its mentioned
  69. in `Profibuch') but i don't know yet if it works as advertised everywhere
  70. including falcons...  if it does i think we can finally implement local
  71. mode, fast RAW IO without hacks in user processes, real cooked mode, etc.
  72.  
  73. Index: types.h
  74. @@ -19,4 +19,13 @@
  75.      short buflen, head, tail, low_water, hi_water;
  76.  } IOREC_T;
  77.  
  78. +/* Bconmap struct, * returned by Bconmap(-2) */
  79. +typedef struct {
  80. +    struct {
  81. +        long bconstat, bconin, bcostat, bconout, rsconf;
  82. +        IOREC_T    *iorec;
  83. +    } *maptab;
  84. +    short    maptabsize;
  85. +} BCONMAP2_T;
  86. +
  87.  #endif
  88. Index: bios.c
  89. @@ -11,6 +11,12 @@
  90.  #include "mint.h"
  91.  #include "xbra.h"
  92.  
  93. +#ifdef __GNUC__
  94. +#define INLINE inline
  95. +#else
  96. +#define INLINE
  97. +#endif
  98. +
  99.  #define UNDEF 0        /* should match definition in tty.c */
  100.  
  101.  /* some key definitions */
  102. @@ -66,6 +72,34 @@
  103.  #define xcostat ((long *)0x55eL)
  104.  #define xconout    ((long *)0x57eL)
  105.  
  106. +#if 1
  107. +/* if the system has Bconmap the ones >= 6 are in a table available
  108. + * thru Bconmap(-2)...
  109. + */
  110. +#define MAPTAB (bconmap2->maptab)
  111. +
  112. +/* and then do BCOSTAT ourselves, the BIOS SCC ones are often broken */
  113. +#define BCOSTAT(dev) \
  114. +    (((unsigned)dev <= 4 && tosvers > 0x0102) ? \
  115. +       (int)callout1(xcostat[dev], dev) : \
  116. +       ((has_bconmap && (unsigned)((dev-SERDEV) <= btty_max)) ? \
  117. +        bcxstat(MAPTAB[dev-SERDEV].iorec+1) : Bcostat(dev)))
  118. +#define BCONOUT(dev, c) \
  119. +    (((unsigned)dev <= 4 && tosvers > 0x0102) ? \
  120. +       callout2(xconout[dev], dev, c) : \
  121. +       ((has_bconmap && (unsigned)((dev-SERDEV) <= btty_max)) ? \
  122. +        callout2(MAPTAB[dev-SERDEV].bconout, dev, c) : Bconout(dev, c)))
  123. +#define BCONSTAT(dev) \
  124. +    (((unsigned)dev <= 4 && tosvers > 0x0102) ? \
  125. +       (int)callout1(xconstat[dev], dev) : \
  126. +       ((has_bconmap && (unsigned)((dev-SERDEV) <= btty_max)) ? \
  127. +        (int)callout1(MAPTAB[dev-SERDEV].bconstat, dev) : Bconstat(dev)))
  128. +#define BCONIN(dev) \
  129. +    (((unsigned)dev <= 4 && tosvers > 0x0102) ? \
  130. +       callout1(xconin[dev], dev) : \
  131. +       ((has_bconmap && (unsigned)((dev-SERDEV) <= btty_max)) ? \
  132. +        callout1(MAPTAB[dev-SERDEV].bconin, dev) : Bconin(dev)))
  133. +#else
  134.  #define BCOSTAT(dev) \
  135.      ((tosvers > 0x0102 && (unsigned)dev <= 4) ? \
  136.         (int)callout1(xcostat[dev], dev) : Bcostat(dev))
  137. @@ -78,6 +112,7 @@
  138.  #define BCONIN(dev) \
  139.      ((tosvers > 0x0102 && (unsigned)dev <= 4) ? \
  140.         callout1(xconin[dev], dev) : Bconin(dev))
  141. +#endif
  142.  #else
  143.  #define BCOSTAT(dev) Bcostat(dev)
  144.  #define BCONOUT(dev,c) Bconout(dev,c)
  145. @@ -87,8 +122,19 @@
  146.  
  147.  /* variables for monitoring the keyboard */
  148.  IOREC_T    *keyrec;        /* keyboard i/o record pointer */
  149. +BCONMAP2_T *bconmap2;        /* bconmap struct */
  150.  short    kintr = 0;        /* keyboard interrupt pending (see intr.s) */
  151.  
  152. +/* replacement *costat for BCOSTAT above */
  153. +INLINE static int bcxstat (wrec)
  154. +IOREC_T *wrec;
  155. +{
  156. +    unsigned s = wrec->head - wrec->tail;
  157. +    if ((int)s <= 0)
  158. +        s += wrec->buflen;
  159. +    return s < 3 ? 0 : -1;
  160. +}
  161. +
  162.  /* Getmpb is not allowed under MiNT */
  163.  
  164.  long ARGS_ON_STACK
  165. @@ -746,6 +792,8 @@
  166.  init_bios()
  167.  {
  168.      keyrec = (IOREC_T *)Iorec(1);
  169. +    if (has_bconmap)
  170. +        bconmap2 = (BCONMAP2_T *)Bconmap(-2);
  171.  }
  172.  
  173.  /*
  174. Index: xbios.c
  175. @@ -23,6 +23,9 @@
  176.               * of TOS which supports Bconmap
  177.               */
  178.  
  179. +extern BCONMAP2_T *bconmap2;        /* bconmap struct */
  180. +#define MAPTAB (bconmap2->maptab)
  181. +
  182.  /*
  183.   * Supexec() presents a lot of problems for us: for example, the user
  184.   * may be calling the kernel, or may be changing interrupt vectors
  185. @@ -143,8 +146,12 @@
  186.      int dev;
  187.  {
  188.      TRACE(("Iorec(%d)", dev));
  189. -    if (dev == 0 && has_bconmap)
  190. +    if (dev == 0 && has_bconmap) {
  191. +/* get around another BIOS Bug:  in (at least) TOS 2.05 Iorec(0) is broken */
  192. +        if (curproc->bconmap >= 6)
  193. +            return (long)MAPTAB[curproc->bconmap-6].iorec;
  194.          mapin(curproc->bconmap);
  195. +    }
  196.      return (long)Iorec(dev);
  197.  }
  198.  
  199. @@ -155,12 +162,21 @@
  200.      long rsval;
  201.      static int oldbaud = -1;
  202.      int ret_oldbaud = 0;
  203. +    extern struct tty ttmfp_tty;
  204. +    extern struct bios_tty bttys[];
  205. +    extern short btty_max;
  206.  
  207.      TRACE(("Rsconf(%d,%d,%d,%d,%d,%d)", baud, flow,
  208.          uc, rs, ts, sc));
  209.  
  210. -    if (has_bconmap)
  211. +    if (has_bconmap) {
  212.          mapin(curproc->bconmap);
  213. +/* more bugs...  serial1 is three-wire, requesting hardware flowcontrol
  214. + * on it can confuse BIOS
  215. + */
  216. +        if ((flow & 2) && (unsigned)curproc->bconmap-6 <= btty_max &&
  217. +            bttys[curproc->bconmap-6].rsel == &(ttmfp_tty.rsel))
  218. +            flow &= ~2;
  219.  
  220.  #ifndef DONT_ONLY030_THIS
  221.  /* Note: the code below must be included, even on a 68030, thanks to a bug
  222. @@ -177,7 +193,7 @@
  223.      3. Rsconf() discards any buffered output
  224.          -> use Iorec() to ensure all buffered data was sent before call
  225.  */
  226. -    else if (tosvers < 0x0104) {
  227. +    } else if (tosvers < 0x0104) {
  228.          if (baud == -2) {
  229.              ret_oldbaud = 1;
  230.              baud = -1;
  231. Index: biosfs.c
  232. @@ -6,6 +6,12 @@
  233.  
  234.  /* simple biosfs.c */
  235.  
  236. +#ifdef __GNUC__
  237. +#define INLINE inline
  238. +#else
  239. +#define INLINE
  240. +#endif
  241. +
  242.  #include "mint.h"
  243.  
  244.  extern struct kerinfo kernelinfo;    /* see main.c */
  245. @@ -146,6 +152,38 @@
  246.      {"", 0, 0, 0, 0, 0}
  247.  };
  248.  
  249. +extern BCONMAP2_T *bconmap2;        /* bconmap struct */
  250. +#define MAPTAB (bconmap2->maptab)
  251. +
  252. +/* set/reset bits in SCC w5 */
  253. +INLINE static void scc_set5 (control, setp, bits, iorec)
  254. +volatile char *control;
  255. +int setp;
  256. +unsigned char bits;
  257. +IOREC_T *iorec;
  258. +{
  259. +    volatile char dummy;
  260. +
  261. +    short sr = spl7();
  262. +
  263. +#if 1
  264. +/* sanity check: if the w5 copy at offset 1d has bit 3 off something is wrong */
  265. +    if (!(((char *) iorec)[0x1d] & 8)) {
  266. +        spl(sr);
  267. +        ALERT ("scc_set5: iorec %lx w5 copy has sender enable bit off, w5 not changed", iorec);
  268. +        return;
  269. +    }
  270. +#endif
  271. +    dummy = *((volatile char *) 0xfffffa01);
  272. +    *control = 5;
  273. +    dummy = *((volatile char *) 0xfffffa01);
  274. +    if (setp)
  275. +        *control = (((char *) iorec)[0x1d] |= bits);
  276. +    else
  277. +        *control = (((char *) iorec)[0x1d] &= ~bits);
  278. +    spl(sr);
  279. +}
  280. +
  281.  #define    MAX_BTTY    4    /* 4 bios_tty structs */
  282.  
  283.  struct bios_tty bttys[MAX_BTTY];
  284. @@ -231,12 +269,16 @@
  285.              b->next = 0;
  286.              break;
  287.          }
  288. -    /* SERIAL2 is not present on the Mega STe or Falcon */
  289. +    /* SERIAL1(!) is not present on the Mega STe or Falcon,
  290. +     * device 8 is SCC channel A
  291. +     */
  292.          if (mch != TT && b->private == 8) {
  293. +            b->name[6] = '2';    /* "serial2" */
  294. +            b->tty = &scca_tty;
  295.              b->next = 0;
  296.              break;
  297.          }
  298. -            
  299. +
  300.      }
  301.      bdevlast = b;
  302.      if (b->name[0] == 0) {
  303. @@ -1347,7 +1389,6 @@
  304.          break;
  305.      case TIOCFLUSH:
  306.          {
  307. -        int oldmap;
  308.          IOREC_T *ior;
  309.          int flushtype;
  310.          short sr;
  311. @@ -1360,13 +1401,10 @@
  312.              flushtype = (int) *r;
  313.          }
  314.          if (dev == 1 || dev >= 6) {
  315. -/* trick uiorec into setting the correct port (it uses curproc->bconmap) */
  316. -            oldmap = curproc->bconmap;
  317. -            if (has_bconmap)
  318. -                curproc->bconmap = (dev == 1)
  319. -                        ? curproc->bconmap
  320. -                        : dev;
  321. -            ior = (IOREC_T *) uiorec(0);
  322. +            if (has_bconmap && dev >= 6)
  323. +                ior = MAPTAB[dev-6].iorec;
  324. +            else
  325. +                ior = (IOREC_T *) uiorec(0);
  326.              if (flushtype & 1) {
  327.                  sr = spl7();
  328.                  ior->head = ior->tail = 0;
  329. @@ -1378,7 +1416,6 @@
  330.                  ior->head = ior->tail = 0;
  331.                  spl(sr);
  332.              }
  333. -            curproc->bconmap = oldmap;
  334.          } else if (dev == 3 || dev == 2 || dev == 5) {
  335.              if (dev == 3) {
  336.                  /* midi */
  337. @@ -1397,23 +1434,18 @@
  338.          }
  339.      case TIOCOUTQ:
  340.          {
  341. -        int oldmap;
  342.          IOREC_T *ior;
  343.  
  344.          dev = f->fc.aux;
  345.  
  346.          if (dev == 1 || dev >= 6) {
  347. -/* trick uiorec into setting the correct port (it uses curproc->bconmap) */
  348. -            oldmap = curproc->bconmap;
  349. -            if (has_bconmap)
  350. -                curproc->bconmap = (dev == 1)
  351. -                        ? curproc->bconmap
  352. -                        : dev;
  353. -            ior = (IOREC_T *) uiorec(0) + 1;
  354. +            if (has_bconmap && dev >= 6)
  355. +                ior = MAPTAB[dev-6].iorec + 1;
  356. +            else
  357. +                ior = (IOREC_T *) uiorec(0) + 1;
  358.              *r = ior->tail - ior->head;
  359.              if (*r < 0)
  360.                  *r += ior->buflen;
  361. -            curproc->bconmap = oldmap;
  362.          }
  363.           else
  364.              *r = 0;
  365. @@ -1450,9 +1482,14 @@
  366.                  oldbaud = baudmap[i];
  367.              *r = oldbaud;
  368.              if (newbaud > 0) {
  369. -    /* BUG: assert DTR works only on modem1 */
  370. +    /* assert DTR works only on modem1 and SCC lines */
  371.                  if (dev == 1 || dev == 6) {
  372.                      Offgibit(0xef);
  373. +                } else if (dev == 7 ||
  374. +                       ((struct tty *)f->devinfo) == &scca_tty) {
  375. +                    scc_set5 ((volatile char *) (dev == 7 ?
  376. +                            0xffff8c85L : 0xffff8c81L),
  377. +                          1, (1 << 7), MAPTAB[dev-6].iorec);
  378.                  }
  379.                  if (newbaud == oldbaud) {
  380.                      curproc->bconmap = oldmap;
  381. @@ -1472,9 +1509,14 @@
  382.                  curproc->bconmap = oldmap;
  383.                  return ERANGE;
  384.              } else if (newbaud == 0L) {
  385. -    /* BUG: drop DTR: works only on modem1 */
  386. +    /* drop DTR: works only on modem1 and SCC lines */
  387.                  if (dev == 1 || dev == 6) {
  388.                      Ongibit(0x10);
  389. +                } else if (dev == 7 ||
  390. +                       ((struct tty *)f->devinfo) == &scca_tty) {
  391. +                    scc_set5 ((volatile char *) (dev == 7 ?
  392. +                            0xffff8c85L : 0xffff8c81L),
  393. +                          0, (1 << 7), MAPTAB[dev-6].iorec);
  394.                  }
  395.              }
  396.              curproc->bconmap = oldmap;
  397. @@ -1500,8 +1542,25 @@
  398.  
  399.          dev = f->fc.aux;
  400.          if (dev == 1 || dev >= 6) {
  401. -            if (has_bconmap)
  402. -                mapin((dev == 1) ? curproc->bconmap : dev);
  403. +            if (has_bconmap) {
  404. +                if (dev == 1)
  405. +                    dev = curproc->bconmap;
  406. +/* YABB (Yet Another BIOS Bug):
  407. +   SCC Rsconf looks for the break bit in the wrong place...  if this
  408. +   dev's Rsconf is in ROM do it ourselves, otherwise assume the user
  409. +   has installed a fix.
  410. +*/
  411. +                if ((dev == 7 ||
  412. +                     ((struct tty *)f->devinfo) == &scca_tty) &&
  413. +                    MAPTAB[dev-6].rsconf > 0xe00000L &&
  414. +                    MAPTAB[dev-6].rsconf < 0xefffffL) {
  415. +                    scc_set5 ((volatile char *) (dev == 7 ?
  416. +                            0xffff8c85L : 0xffff8c81L),
  417. +                          (mode == TIOCSBRK), (1 << 4), MAPTAB[dev-6].iorec);
  418. +                    break;
  419. +                }
  420. +                mapin(dev);
  421. +            }
  422.          } else {
  423.              return EINVFN;
  424.          }
  425. -- 
  426. J"urgen Lock / nox@jelal.north.de / UUCP: ..!uunet!unido!uniol!jelal!nox
  427.                                 ...ohne Gewehr
  428. PGP public key fingerprint =  8A 18 58 54 03 7B FC 12  1F 8B 63 C7 19 27 CF DA 
  429.